package com.atguigu.flink.sql.function;

import org.apache.flink.table.api.EnvironmentSettings;
import org.apache.flink.table.api.TableEnvironment;

/**
 * Created by Smexy on 2023/4/14
 */
public class Demo2_FunctionUse
{
    public static void main(String[] args) {

        EnvironmentSettings environmentSettings = EnvironmentSettings.newInstance().inStreamingMode().build();
        TableEnvironment tableEnvironment = TableEnvironment.create(environmentSettings);

        String createTableSql = " create table t1 ( id STRING, ts BIGINT , vc INT ," +
            "  `file.path` STRING NOT NULL METADATA " +
            "    )WITH (" +
            "  'connector' = 'filesystem'," +
            "  'path' = 'data/sensor.json'," +
            "  'format' = 'json'" +
            ") ";

        tableEnvironment.executeSql(createTableSql);

        /*
              flink内置的函数：
                https://nightlies.apache.org/flink/flink-docs-release-1.16/docs/dev/table/functions/systemfunctions/
              自定义的函数
              引入第三方模块的函数:
                    hive: java
                    flink: java
         */
        tableEnvironment.sqlQuery(" select *,rand() randNum from t1  ").execute().print();

    }
}
